home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr27 / gs26.zip / MERGEINI.PS < prev    next >
Text File  |  1992-11-24  |  2KB  |  94 lines

  1. %    Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2. %    Distributed by Free Software Foundation, Inc.
  3. %
  4. % This file is part of Ghostscript.
  5. %
  6. % Ghostscript is distributed in the hope that it will be useful, but
  7. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. % to anyone for the consequences of using it or for whether it serves any
  9. % particular purpose or works at all, unless he says so in writing.  Refer
  10. % to the Ghostscript General Public License for full details.
  11. %
  12. % Everyone is granted permission to copy, modify and redistribute
  13. % Ghostscript, but only under the conditions described in the Ghostscript
  14. % General Public License.  A copy of this license is supposed to have been
  15. % given to you along with Ghostscript so you can know your rights and
  16. % responsibilities.  It should be in a file named COPYING.  Among other
  17. % things, the copyright notice and this notice must be preserved on all
  18. % copies.
  19.  
  20. % mergeini.ps - utility for merging all the Ghostscript initialization files
  21. % (gs_*.ps) into a single file.
  22.  
  23. /rl { in =string readline } def
  24. /wl { out exch writestring out (\n) writestring } def
  25. /infile { findlibfile { exch pop } { (r) file } ifelse } def
  26.  
  27. /merge            % <in_name> <out_name> <squash>
  28.  { /squash exch def
  29.    exch infile
  30.    exch (w) file /out exch def
  31.  
  32.     % Copy comments up to the first blank line,
  33.     % since this is the legal notice for the file.
  34.    /in exch def
  35.     { rl pop dup wl
  36.       () eq { exit } if
  37.     }
  38.    loop
  39.  
  40.    in mergefile
  41.    out closefile
  42.  } def
  43.  
  44. /doit            % <string> -> <string> true | false
  45.  { squash
  46.     { dup () eq
  47.        { pop false
  48.        }
  49.        { dup 0 1 getinterval (%) ne
  50.           { true
  51.       }
  52.       { dup (%END) anchorsearch
  53.          { pop pop true
  54.          }
  55.          { pop pop false
  56.          }
  57.         ifelse
  58.       }
  59.      ifelse
  60.        }
  61.       ifelse
  62.     }
  63.     { true
  64.     }
  65.    ifelse
  66.  } def
  67.  
  68. /mergefile        % <in_file>
  69.  { /in exch def
  70.     { rl not { pop exit } if
  71.       (%% Replace ) anchorsearch
  72.        { pop
  73.          in exch
  74.          token pop            % # of lines
  75.      exch token pop exch pop    % file name or list name
  76.      exch
  77.           { rl pop pop }
  78.      repeat
  79.      exec dup type /stringtype eq { [ exch ] } if
  80.       { infile mergefile
  81.       }
  82.      forall
  83.      /in exch def
  84.        }
  85.        { doit { wl } if
  86.        }
  87.       ifelse
  88.     } loop
  89.    in closefile
  90.  } def
  91.  
  92. (gs_init.ps) (gs_xinit.ps) true merge
  93. quit
  94.